#!/bin/bash

#将百度refer的次数和被链接的次数merge到一个文件中

refer_stat="/data/link_analyse/baidu_refer_stat_sort.txt"
link_stat="/data/link_analyse/in_link_stat.txt"

awk '
FILENAME==ARGV[1]{
    referStat[$1] = $2;
}
FILENAME==ARGV[2]{
    linkStat[$1] = $2;
}
END {
    for (i = 1; i < 2442583; ++i) {
        if (i in linkStat) {
            linkNum = linkStat[i];
        }
        else linkNum = 0;
        if (i in referStat) {
            referNum = referStat[i];
        }
        else referNum = 0;
        if (referNum !=0 || linkNum != 0) print i, linkNum, referNum;
    }
}' $refer_stat $link_stat > /data/link_analyse/merge_stat.txt
